from hashlib import sha1

def IsComeFromWx(token : str, args : dict) -> bool:
    try:
        signature = args['signature'][0]
        timestamp = args['timestamp'][0]
        nonce = args['nonce'][0]
    except KeyError:
        return False

    t = [token, timestamp, nonce]
    t.sort()
    sorted_str = ''.join(t)
    hash_str = sha1(sorted_str.encode('utf-8')).hexdigest()

    return signature == hash_str